﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.VisualStudio.TestTools.UnitTesting;

using Pibby.Core.Playlist;

namespace Pibby.Core.Tests
{
	[TestClass]
	public class CanonicalPlaylistBuilderTests
	{
		[TestMethod]
		public void Build_RootedFolder_AppendsRootFolderToPath()
		{
			MediaPlaylist playlist = new MediaPlaylist ();
			
			for (int i = 0; i < 10; ++i)
			{
				playlist.Items.Add (new PlaylistItem (string.Format ("EBook - Chapter {0}", i + 1)));
			}

			string rootedFolder = "z:\\Ebooks";
			var collection = CanonicalPlaylistBuilder.Build(playlist, rootedFolder);

			Assert.AreEqual(10, collection.Count);

			foreach (PlaylistItem item in collection)
			{
				Assert.IsTrue(item.Path.StartsWith(rootedFolder));
			}
		}

		[TestMethod]
		public void Build_RelativeFolder_MovesFolderToNewPath()
		{
			MediaPlaylist playlist = new MediaPlaylist();

			for (int i = 0; i < 10; ++i)
			{
				playlist.Items.Add(new PlaylistItem(string.Format("..\\eBooks\\EBook - Chapter {0}", i + 1)));
			}

			string relativeFolder = "Podcasts";
			var collection = CanonicalPlaylistBuilder.Build(playlist, relativeFolder);

			Assert.AreEqual(10, collection.Count);

			foreach (PlaylistItem item in collection)
			{
				Assert.IsTrue(item.Path.StartsWith(relativeFolder));
			}
		}
	}
}
